using Awesome.Extensions.Enumerable;
using Awesome.Extensions.QualityTools;
using Awesome.Extensions.String;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Awesome.Extensions.Tests
{
    [TestClass]
    public class StringsTest
    {
        [TestMethod]
        public void TestJoins()
        {
            IE.New("ok", "lol")
                .Glue("")
                .AssertEquals("oklol");

            IE.New(10, 20, 30, 40, 50, 60)
                .Glue(',')
                .AssertEquals("10,20,30,40,50,60");

            IE.New<string>()
                .Glue(',')
                .AssertEquals("");

            IE.New("yo")
               .Glue(',')
               .AssertEquals("yo");
        }

        [TestMethod]
        public void TestEquals()
        {
            "abcder".EqualsIgnoreCase("ABcdEF").AssertTrue();
            "abcder".CompareTo("abcix").AssertEquals("ABcdEF".CompareIgnoreCase("abcix"));
        }

        [TestMethod]
        public void TestNewLines()
        {
            var lines = "lol\nok\r\n\r\rfoo\nbar\n".SplitByNewLines();

            lines.AssertSequenceEqual("lol", "ok", "", "", "foo", "bar", "");
        }

        [TestMethod]
        public void TestSkips()
        {
            IE.New("", "10", "lol", null, "", "FOOBAR")
                .SkipEmpty()
                .AssertSequenceEqual("10", "lol", null, "FOOBAR");

            IE.New("", "10", "lol", null, "", "FOOBAR")
                .SkipNullOrEmpty()
                .AssertSequenceEqual("10", "lol", "FOOBAR");

        }
    }
}